
import { createApp } from 'vue'
import App from './App.vue'
import router from './medical/m-router/router_tool'
import { createPinia } from 'pinia'
import panelhander from './medical/m-components/panelhander.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'




//路由守卫
router.beforeEach((to,from)=>{
  const token=localStorage.getItem('pz_token')
  //非登录页面token不存在
  if(!token &&to.path !== '/login'){
    return '/login'
  }else if(token && to.path==='/login'){
    return '/'
  }else{
    return true
  }
})



const app=createApp(App)
const pinia=createPinia()

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(pinia)

app.use(router)


app.component('panelhander',panelhander)

app.mount('#app')